package com.hmall.search.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Data
@NoArgsConstructor
public class ItemDoc {
    private Long id; //商品id
    private String name; //商品名称
    private String brand; //品牌名称
    private String category; //分类名称
    private Long price; //价格（分）
    private Integer sold; //销量
    private Integer commentCount; //评论数
    private Integer stock; //库存数量
    private String spec; //规格
    private Boolean isAD; //用于广告权重

    //用于存储下拉框自动补全数据
    private List<String> suggestion;

    public ItemDoc(Item item){
        this.id = item.getId();
        this.name = item.getName();
        this.brand = item.getBrand();
        this.category = item.getCategory();
        this.price = item.getPrice();
        this.sold = item.getSold();
        this.commentCount = item.getCommentCount();
        this.stock = item.getStock();
        this.spec = item.getSpec();
        this.isAD = item.getIsAD();

        //将分类/品牌作为自动补全数据
        this.suggestion = Arrays.asList(this.brand, this.category);

    }

}
